package com.example.spring.Controller;

import com.example.spring.Dto.*;
import com.example.spring.Service.ProductDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ProductDetailsController {

    @Autowired
    private ProductDetailsService productDetailsService;

    //统计每个省份的客户数量
    @GetMapping("/orders_summary_json")
    public List<ProvinceCustomerCountDTO> countCustomersByProvince() {
        return productDetailsService.countCustomersByProvinceFromSalesRecords();
    }

    //客户数量前10的省份
    @GetMapping("/order-count-by-year")
    public List<ProvinceCustomerCountDTO> getTop10ProvincesByCustomerCount() {
        return productDetailsService.getTop10ProvincesByCustomerCountFromSalesRecords();
    }


    //数据总订单数量
    @GetMapping("/total-order-count")
    public OrderCountDTO getTotalOrderCount() {
        return productDetailsService.getTotalOrderCount();
    }

    //各个区域的客户订单数占比
    @GetMapping("/region-order-counts")
    public List<RegionOrderCountDTO> getRegionOrderCounts() {
        return productDetailsService.getRegionOrderCounts();
    }

    //各个区域的客户订单数
    @GetMapping("/region-order-count")
    public List<RegionOrderCount> getRegionOrderCount() {
        return productDetailsService.getRegionOrderCount();
    }

}

